package com.szrt.java.day20161227.demo04;

import java.util.Arrays;
import java.util.Scanner;

import org.junit.Test;

public class QueryArray01 {

	@Test
	public void query(){
		
		int[] array = new int[]{5,8,4,9,2,1,};
		
		System.out.print("该数组为："+Arrays.toString(array));
		System.out.println();
		System.out.println("请输入你要查询的数字：");
		
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		sc.close();
		
		for(int index =0;index<array.length;index++){
			int temp = array[index];
			if(array[index]==num){
				System.out.println("你要查询数字 "+temp+" 的数组下标为："+index);
				break;
			}
		}
		
	}
	
}
